using System;
using BitMango;
using BMCommon;
using Data;
using UnityEngine;

public class SettingPopupHandler : MonoBehaviour, IPopupWnd, IHandlerBase
{
	public void DoDataExchange()
	{
	}

	public void OnEnterPopup(object param)
	{
		this.SetBtn();
		this.btnGDPR.SetActive(Platform.IsEU());
	}

	public void OnLeavePopup()
	{
	}

	private void Close()
	{
		BMSoundHelper.Play("se_btnclick", false, 1f);
		Scene.ClosePopup("SettingPopup", "CLOSE");
	}

	private void OnClickSupport()
	{
		BMSoundHelper.Play("se_btnclick", false, 1f);
		Platform.SetRecoverPoint("help");
		Share.SendFeedback();
	}

	private void OnClickSettingBgm()
	{
		DataContainer<Data.Root>.Data.options.record.bgm = !DataContainer<Data.Root>.Data.options.record.bgm;
		BMSoundHelper.EnableBGM = !BMSoundHelper.EnableBGM;
		DataContainer<Data.Root>.Data.options.SaveContext();
		SingletonMonoBehaviour<Director>.Instance.BGMSetting();
		BMSoundHelper.Play("se_btnclick", false, 1f);
		this.SetBtn();
	}

	private void OnClickSettingSfx()
	{
		DataContainer<Data.Root>.Data.options.record.sfx = !DataContainer<Data.Root>.Data.options.record.sfx;
		BMSoundHelper.EnableSFX = !BMSoundHelper.EnableSFX;
		DataContainer<Data.Root>.Data.options.SaveContext();
		SingletonMonoBehaviour<Director>.Instance.SFXSetting();
		BMSoundHelper.Play("se_btnclick", false, 1f);
		this.SetBtn();
	}

	private void OnClickNotice()
	{
		BMSoundHelper.Play("se_btnclick", false, 1f);
		DataContainer<Data.Root>.Data.options.record.notice = !DataContainer<Data.Root>.Data.options.record.notice;
		DataContainer<Data.Root>.Data.options.SaveContext();
		if (DataContainer<Data.Root>.Data.options.record.notice)
		{
			BlockAlarm.RegisterAlarm();
		}
		else
		{
			BlockAlarm.AllUnRegister();
		}
		this.SetBtn();
	}

	private void OnClickBack()
	{
		BMSoundHelper.Play("se_btnclick", false, 1f);
		Scene.ClosePopup("SettingPopup", "BACK");
	}

	private void OnClickGDPR()
	{
		BMSoundHelper.Play("se_btnclick", false, 1f);
		BMConsent.ShowOptOutAdsSetting(null);
	}

	private void SetBtn()
	{
		this.bgmIcon.spriteName = ((!DataContainer<Data.Root>.Data.options.record.bgm) ? "icon_bgm_off" : "icon_bgm_on");
		this.sfxIcon.spriteName = ((!DataContainer<Data.Root>.Data.options.record.sfx) ? "icon_sfx_off" : "icon_sfx_on");
		this.noticeIcon.spriteName = ((!DataContainer<Data.Root>.Data.options.record.notice) ? "icon_noti_off" : "icon_noti_on");
		this.bgmLabel.spriteName = ((!DataContainer<Data.Root>.Data.options.record.bgm) ? "setting_btn_bg_inactive" : "setting_btn_bg_active");
		this.sfxLabel.spriteName = ((!DataContainer<Data.Root>.Data.options.record.sfx) ? "setting_btn_bg_inactive" : "setting_btn_bg_active");
		this.noticeLabel.spriteName = ((!DataContainer<Data.Root>.Data.options.record.notice) ? "setting_btn_bg_inactive" : "setting_btn_bg_active");
	}

	private void OnEscape()
	{
		BMSoundHelper.Play("se_btnclick", false, 1f);
		Scene.ClosePopup("SettingPopup", "CLOSE");
	}

	[SerializeField]
	private Camera cam;

	[SerializeField]
	private GameObject curtain;

	public tk2dSprite bgmIcon;

	public tk2dSprite sfxIcon;

	public tk2dSprite noticeIcon;

	public tk2dSprite bgmLabel;

	public tk2dSprite sfxLabel;

	public tk2dSprite noticeLabel;

	public GameObject btnGDPR;

	private bool isPlay;
}
